import { LockOutlined } from '@ant-design/icons-vue'
import { validateConfirmPassword } from '@/utils/Validate'
import { reactive, toRefs } from 'vue'
import { useCommon } from '@/stores/Common'

const CommonStore = useCommon()
const { SecondLeafArr } = toRefs(CommonStore)

export const searchConfig = reactive({
    userName: {
        component: "AInput",
        label: "用户名",
        attrs: {
            allowClear: true,
            placeholder: "用户名",
            style: {
                width: '100%'
            }
        }
    },
    departmentWard: {
        component: "ACascader",
        label: "科室",
        attrs: {
            allowClear: true,
            placeholder: "科室",
            changeOnSelect: true,
            options: SecondLeafArr,
            style: {
                width: '100%'
            }
        }
    },
})

export const searchSelfConfig = {
    userName: {
        component: "AInput",
        label: "用户名",
        attrs: {
            allowClear: true,
            placeholder: "用户名",
            style: {
                width: '100%'
            }
        }
    },
}

export const addConfig = reactive({
    userName: {
        component: "AInput",
        label: "用户名",
        attrs: {
            allowClear: true,
            placeholder: "用户名",
            style: {
                width: '100%'
            }
        },
        rules: [{ required: true, message: "请输入用户名", trigger: 'blur' }]
    },
    login: {
        component: "AInput",
        label: "账号",
        attrs: {
            allowClear: true,
            placeholder: "账号",
            style: {
                width: '100%'
            }
        },
        rules: [{ required: true, message: "请输入账号", trigger: 'blur' }]
    },
    departmentWard: {
        component: "ACascader",
        label: "科室",
        attrs: {
            allowClear: true,
            placeholder: "科室",
            options: SecondLeafArr,
            changeOnSelect: true,
            style: {
                width: '100%'
            }
        },
        rules: [{ required: true, message: "请选择科室", trigger: 'change' }]
    },
})

export const editConfig = reactive({
    userName: {
        component: "AInput",
        label: "用户名",
        attrs: {
            allowClear: true,
            placeholder: "用户名",
            style: {
                width: '100%'
            }
        },
        rules: [{ required: true, message: "请输入用户名", trigger: 'blur' }]
    },
    login: {
        component: "AInput",
        label: "账号",
        attrs: {
            allowClear: true,
            placeholder: "账号",
            style: {
                width: '100%'
            }
        },
        rules: [{ required: true, message: "请输入账号", trigger: 'blur' }]
    },
    departmentWard: {
        component: "ACascader",
        label: "科室",
        attrs: {
            allowClear: true,
            placeholder: "科室",
            options: SecondLeafArr,
            style: {
                width: '100%'
            }
        },
        rules: [{ required: true, message: "请选择科室", trigger: 'change' }]
    },
    password: {
        component: 'AInputPassword',
        label: '密码',
        attrs: {
            allowClear: true,
            placeholder: '密码',
            style: {
                width: '100%'
            }
        },
        slots: [
            { name: 'prefix', component: LockOutlined },
        ],
        rules: [
            { required: true, message: '请输入密码', trigger: 'blur' }
        ]
    },
    secondPass: {
        component: 'AInputPassword',
        label: '确认密码',
        attrs: {
            allowClear: true,
            placeholder: '确认密码',
            style: {
                width: '100%'
            }
        },
        slots: [
            { name: 'prefix', component: LockOutlined },
        ],
        rules: [
            { required: true, validator: validateConfirmPassword, trigger: 'blur' }
        ]
    }
})

export const columns = [
    {
        title: '序号',
        dataIndex: 'index',
        align: 'center',
        width: 80,
        fixed: 'left'
    },
    {
        title: '用户名',
        dataIndex: 'userName',
        align: 'center',
        width: 150
    }, {
        title: '科室',
        dataIndex: 'department',
        width: 300,
        align: 'center',
    },
    {
        title: '登录账号',
        dataIndex: 'login',
        align: 'center',
        width: 150
    },
    {
        title: '操作',
        dataIndex: 'action',
        align: 'center',
        width: 300
    }
]